<?php
/**
 * Created by lunzi.
 * User: lunzi
 * Date: 15-06-03
 * Time: 下午2:41
 */

class Visitor {

    // 访问者信息
    private $_info = NULL;
    private $_signed = FALSE;

    private $_session_key = 'HS_mammon';

    public function __construct()
    {
        if ($info = $this->session->userdata($this->_session_key)){
            $this->_info = $info;
            $this->_signed = TRUE;
        }
    }

    public function is_signed()
    {
        return $this->_signed;
    }

    public function get_info($key = '')
    {
        if ($key) {
            return isset($this->_info[$key]) ? $this->_info[$key] : NULL;
        } else {
            return $this->_info;
        }
    }

    public function assign($info)
    {
        $this->_info = $info;
        $this->session->set_userdata($this->_session_key, $info);
    }

    public function signout()
    {
        $this->session->set_userdata($this->_session_key, NULL);
    }

    function __get($key)
    {
        $CI =& get_instance();
        return $CI->$key;
    }
} 